import FBook from 'FBook';

var GameData = require('../module/gameData')();

cc.Class({
    extends: cc.Component,

    properties: {},

    // LIFE-CYCLE CALLBACKS:
    /*
    * 18519322480
    * game@1234
    * */
    onLoad() {
        this.node.on(cc.Node.EventType.TOUCH_START, this.selectBtn, this);
        var playerName = FBook.getInfoType("getName");
        var userID = FBook.getInfoType("userID");

        var playerLocal = FBook.getInfoType("playerLocal");
        var getUserInfo = FBook.getInfoType("getUserInfo");
        setTimeout(function () {
            cc.director.preloadScene("Home", function () {
            });
        }, 200);
        console.log("isFaceBook_name_ID..", playerName, userID, playerLocal, getUserInfo);
    },
    selectBtn() {
        cc.find("loading").active = true;
        this.fishData = GameData.getlocalData("fishData");
        if (!this.fishData.isfirstHome) {
            this.fishData.isfirstHome=true;
            GameData.savelocalData(this.fishData);
            cc.director.preloadScene("cg", function () {
                cc.find("loading").active = false;
                cc.director.loadScene("cg");
            });
        } else {
            cc.director.preloadScene("Home", function () {
                cc.find("loading").active = false;
                cc.director.loadScene("Home");
            });
        }
    },
    start() {

    },

    // update (dt) {},
});
